<template>
<div class="loan-info">
  <x-header v-if="iswxXcx !='wxBank'" :left-options="{backText: ''}" :title="$route.name"><router-link to="/" slot="right"> <van-icon name="wap-home-o" size="26"/> </router-link></x-header>
  <div class="loan-bg">
    <!-- <div class="logo"><img :src="require('@/assets/logo_regUnit.png')" alt=""></div> -->
    <Group label-align="right" label-width="5em" label-margin-right="2em">
        <div class="loanEntryInfo-box">
          <label class="label">姓名</label>
          <input v-model="name" placeholder="请输入姓名">
        </div>
        <div class="loanEntryInfo-box">
          <label class="label">身份证号</label>
          <input v-model="idcardNo" maxlength="18" placeholder="请输入身份证号">
        </div>
    </Group>
    <div class="Batch-box"><XButton :gradients="['#FF4A32', '#e99185']" class="myBtn" @click.native="btnClick">查询</XButton></div>
  </div>
</div>
</template>
<script>
import { Group, XButton } from "vux";
import { Icon } from 'vant';
import {
    gzInput
  } from '@/components/customize'
export default {
  name: "loanEntryInfo",
  components: {
    Group,
    XButton,
    [Icon.name]: Icon,
    gzInput,
  },
  data() {
    return {
      name:'',//姓名
      idcardNo:'',//身份证号
      iswxXcx: '',//是否是微信小程序   如果是不像是标题栏
    };
  },
  created() {
    this.iswxXcx = process.env.Equipment;
  },
  methods: {
    btnClick() {
      if (!this.name || !this.idcardNo) {
        this.$vux.toast.show({
          type: "warn",
          text: "请填写用户信息！"
        });
        return;
      }
      this.idcardNo = this.idcardNo.trim();
      if (!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/gi.test(this.idcardNo))) {
        this.$vux.toast.show({
          type: "warn",
          text: "请填写正确身份证号码！"
        });
        return;
      }
      this.$vux.loading.show({
        text: '正在查询...'
      })
      // 查询是否有可用额度
      let defer = this.baseService.postForm(this.__ctx + "/gz/api/quota/quotaFlag", {
        CORE_CST_NO: this.name, //核心客户号  017000408912
        NUM_OF_IDV_ID_DOC: this.idcardNo, //客户证件号
      });
      defer.then(data => {
        this.$vux.loading.hide();
        if (data.isOk) {
          var info = {
            name: this.name,
            idcardNo: this.idcardNo,
            DDLN_FLAG: data.data.DDLN_FLAG,
            TLMT_FLAG: data.data.TLMT_FLAG
          }
          localStorage.setItem("rdsuserinfo", JSON.stringify(info));
          this.$router.push("/bpm/agriculturalLoan");
        } else {
          this.$vux.toast.show({
            type: "warn",
            text: data.msg
          });
        }
      });
    },
    // 获取用户额度
    // getQuota() {
    //   let defer = this.baseService.postForm(this.__ctx + "/gz/api/quota", {
    //     CORE_CST_NO: this.name, //核心客户号
    //     NUM_OF_IDV_ID_DOC: this.idcardNo, //客户证件号
    //   });
    //   defer.then(data => {
    //     if (data.isOk) {
    //       let _this = this;
    //       // this.$vux.toast.show({
    //       //   text: data.msg,
    //       //   onHide() {
    //           _this.$router.push("/bpm/agriculturalLoan");
    //       //   }
    //       // });
    //     } else {
    //       this.$vux.toast.show({
    //         type: "warn",
    //         text: data.msg
    //       });
    //     }
    //   });
    // }
  }
};
</script>

<style scoped lang="less">
.loan-info {
  min-height: 100vh;
  background: #ffffff;
}
.loan-bg{
  width: 100%;
  min-height: 80vh;
  // background-image: url("../../assets/loan-info-bg.png");
  background-repeat: no-repeat;
  background-size: 100%;
  padding-top: 1px;

  .logo{
    width: 60%;
    margin: 16vh auto 50px;
    img{
      width: 100%;
    }
  }
}
/deep/.weui-cells{
  margin: 17px;
  background-color: transparent;
  .loanEntryInfo-box{
    width: 100%;
    min-height: 3em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E5E6EB;
    font-size: 1.1em;
    &:last-child{
      border: 0;
    }
  }
  .label{
    width: 5em;
    min-width: 5em;
    text-align: left!important;
    &::after {
      content: '*';
      color: red;
    }
  }
  input{
    width: 100%;
    text-align: right;
    border: 0;
    background-color: transparent;
  }
}
.Batch-box{
  width: 100%;
  padding: 0;
  margin-top: 60px;
  .myBtn {
    width: calc(~"100% - 34px");
    height: 3em;
    margin: 11px 17px;
    text-align: center;
    background: #FF4A32!important;
    border-radius: 4px 4px 4px 4px;
    font-size: 1.33em;
    font-family: PingFang SC-Semibold, PingFang SC;
    font-weight: 600;
    color: #FFFFFF;
  }
}
</style>
